package com.example.controller;

import com.example.common.Result;
import com.example.entity.User;
import com.example.service.UserService;
import com.example.service.LoginService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
public class LoginController {

    @Resource
    LoginService loginService;
    @Resource
    UserService userService;

    @PostMapping("/login")
    public Result login(@RequestBody User user){
        User dbuser = loginService.login(user);
        return Result.success(dbuser);
    }

    @PostMapping("/register")
    public Result register(@RequestBody User user){
        userService.add(user);
        return Result.success();
    }
}